package ar.com.solidussource.howmuchmobile.activities;

import android.content.Intent;
import ar.com.solidussource.howmuchmobile.activities.generic.PaginatedGenListDialogActivity;
import ar.com.solidussource.howmuchmobile.common.entities.Market;
import ar.com.solidussource.howmuchmobile.common.exception.ServiceException;
import ar.com.solidussource.howmuchmobile.common.utils.MarketCluster;

/**
 * Created with IntelliJ IDEA.
 * User: FT31270775
 * Date: 19/11/12
 * Time: 17:59
 * To change this template use File | Settings | File Templates.
 */
public class MarketClusterListActivity extends PaginatedGenListDialogActivity<Market> {

    @Override
    public void serviceCall() throws ServiceException {
        MarketCluster marketCluster = (MarketCluster) getIntent().getExtras().get("marketCluster");
        data.addAll(marketCluster.getMarkets());

    }

    @Override
    public Integer getElementId(int position) {
        return data.get(position).getId();
    }

    @Override
    public String getElementName(int position) {
        return data.get(position).getName();
    }

    @Override
    public void onElementClick(int position) {

        Intent intent = new Intent(this, MarketDetailOnMapActivity.class);
        intent.putExtra("market", data.get(position));
        startActivity(intent);

    }
}